package com.example.dao.impl;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.example.dao.TextDao;
import com.example.db.DBHelper;
import com.example.model.LEARNTEXT;

public class TextDaoImpl implements TextDao {
	
	String table = "learntext";

	@Override
	public List<LEARNTEXT> getListById(Context context, int id) {
		List<LEARNTEXT> list = new ArrayList<LEARNTEXT>();
		String sql = "select * from "+table+" where _id = "+id;
		Cursor cursor = DBHelper.getDB(context).rawQuery(sql, null);
		while(cursor.moveToNext()){
			LEARNTEXT learntext = new LEARNTEXT();
			learntext.setArm(cursor.getString(cursor.getColumnIndex("arm")));
			learntext.setId(cursor.getInt(cursor.getColumnIndex("_id")));
			learntext.setName(cursor.getString(cursor.getColumnIndex("name")));
			learntext.setText(cursor.getString(cursor.getColumnIndex("text")));
			list.add(learntext);
		}
		return list;
	}

}
